//
//  ActivityViewController.m
//  MeiLiProductModel
//
//  Created by B505 on 15/2/21.
//  Copyright (c) 2015年 孙晓林. All rights reserved.
//

#import "ActivityViewController.h"
#import "PublicMethod.h"
#import "UILabel+Utils.h"
#import "T4Marco.h"

#define kActivityViewHeight SCREEN_HEIGHT / 3
#define kBlurViewY 93
#define kTitleLabelFromTopHeight 13
#define kTitleLabelFromTopWidth 12
@interface ActivityViewController ()
{
    NSArray *resourceArray;
    NSArray *titleArray;
}
@property (nonatomic, strong) UIScrollView *scrollView;

@end

@implementation ActivityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    resourceArray = @[@"pic2.jpg", @"pic1.jpg", @"pic2.jpg", @"pic_detail.jpg"];
    titleArray = @[@"作为启蒙的艺术", @"M Home: 随寓而安 ——红星美凯龙艺术大展", @"一个中的一个个:无形工作室n个个展", @"作为启蒙的艺术"];
    
    _scrollView = [[UIScrollView alloc]init];
    _scrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    _scrollView.bounces = YES;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.alwaysBounceVertical = YES;
    [self.view addSubview:_scrollView];
    NSDictionary *firstAtt = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:16],
                    NSForegroundColorAttributeName: [UIColor whiteColor]};
    NSDictionary *secondAtt = @{NSFontAttributeName: [UIFont systemFontOfSize:13],
                               NSForegroundColorAttributeName: [UIColor whiteColor]};
    CGSize distanceLabelSize = [PublicMethod GetSizeFromString:@"中国国家博物馆-0.6km" withAttributes:secondAtt];
    for (int i = 0; i < resourceArray.count; i ++) {
        UIImage *image = [PublicMethod cutImage:[UIImage imageNamed:resourceArray[i]] WithImageViewWidth:SCREEN_WIDTH WithImageViewHeight:kActivityViewHeight];
        UIImageView *showImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, kActivityViewHeight * i, SCREEN_WIDTH, kActivityViewHeight)];
        showImageView.image = image;
        showImageView.layer.cornerRadius = 5.0;
        showImageView.layer.shadowColor = [UIColor blackColor].CGColor;
        showImageView.layer.shadowOpacity = 0.9;
        showImageView.layer.shadowRadius = 8;
        showImageView.layer.shadowOffset = CGSizeMake(0, -3);
        [_scrollView addSubview:showImageView];
        
        CGSize titleLabelSize = [PublicMethod GetSizeFromString:titleArray[i] withAttributes:firstAtt];
        UIView *blurView = [[UIView alloc]initWithFrame:CGRectMake(0, kBlurViewY, titleLabelSize.width + 28 + kTitleLabelFromTopWidth, kTitleLabelFromTopHeight * 2 + titleLabelSize.height + distanceLabelSize.height + 8)];
        blurView.backgroundColor = [UIColor blackColor];
        blurView.alpha = 0.6;
        
        UILabel *titleLabel = [UILabel labelWithFrame:CGRectMake( kTitleLabelFromTopWidth, kTitleLabelFromTopHeight + kBlurViewY , titleLabelSize.width, titleLabelSize.height) font:[UIFont boldSystemFontOfSize:15] textAlignment:NSTextAlignmentLeft textColor:[UIColor whiteColor] highlightedTextColor:[UIColor whiteColor]];
        titleLabel.text = titleArray[i];
        
        UILabel *distanceLabel = [UILabel labelWithFrame:CGRectMake(kTitleLabelFromTopWidth, kBlurViewY +kTitleLabelFromTopHeight + titleLabelSize.height + 8, distanceLabelSize.width, distanceLabelSize.height) font:[UIFont systemFontOfSize:13] textAlignment:NSTextAlignmentLeft textColor:[UIColor whiteColor] highlightedTextColor:[UIColor whiteColor]];
        distanceLabel.text = @"中国国家博物馆-0.6km";
        
       
        [showImageView addSubview:blurView];
        [showImageView insertSubview:titleLabel aboveSubview:blurView];
        [showImageView insertSubview:distanceLabel aboveSubview:blurView];

        
        
    }
    
    _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, kActivityViewHeight * resourceArray.count);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    NSLog(@"出现内存泄露");
}

@end
